<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>用户登录</title>
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel='stylesheet'
	href='http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css'>
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src='http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js'></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src='http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js'></script>
<style>
.slot {
	margin-top: 100px;
}

@media ( max-width :330px) {
	.slot {
		margin-top: 40px;
	}
}
</style>
<script type="text/javascript">
	$(function() {
		if ('' != '${result.value.userName}') {
			$('#username').val('${result.value.userName}').keyup();
		}
		$('#submit').bind('click', function() {
			$.ajax({
				type : "POST",
				dataType : "json",
				url : "lognController/login.do",
				data : $("form").serialize(),
				success : function(data) {
					if (data && data.successful == true) {
						window.location.replace("home.html");
					} else {

						$('form label').text(data.message);
						$('#submit').removeAttr('disabled');
						//alert("登录失败", data.message, "error");
					}
				},
				error : function(data) {
					alert("error:" + data.responseText);
				}

			});

		})
	})
</script>
</head>
<body>
	<div class="slot"></div>
	<div class='container'>
		<div class="row text-center">
			<div class="col-md-4 col-md-offset-4">
				<form class='form-signin' role='form'>
					<h4 class='form-signin-heading'>用户登录</h4>
					<input type='text' class='form-control' placeholder='请输入用户名' name ="username"
						required autofocus>
					<div style='height: 10px; clear: both; display: block'></div>
					<input
						type='password' name="password"
						class='form-control' placeholder='请输入密码' required>
					<div class='checkbox'>
						<label> <input type='checkbox' value='remember-me'>
							记住登录状态
						</label>
					</div>
					<button class='btn btn-default btn-default-reverse' type='button' id="submit">登录</button>
				</form>
			</div>
		</div>
	</div>
</body>
</html>